import { Body, Controller, Get, Post, Res, Session } from "@nestjs/common"
import { UserService } from "./user.service"
import { Response } from "express"

@Controller("user")
export class UserController {
  constructor(private readonly userService: UserService) {}

  // User register
  @Post("/register")
  async register(
    @Body() body: object,
    @Res() res: Response,
    @Session() session: object
  ): Promise<void> {
    return this.userService.register(body, res, session)
  }

  // User login
  @Post("/login")
  async login(
    @Body() body: object,
    @Res() res: Response,
    @Session() session: object
  ): Promise<void> {
    return this.userService.login(body, res, session)
  }

  // User logout
  @Post("/logout")
  async logout(@Res() res: Response): Promise<void> {
    return this.userService.logout(res)
  }

  // Modify password
  @Post("/update")
  async update(@Res() res: Response): Promise<void> {
    return this.userService.update(res)
  }

  // Soft deletion user
  @Post("/delete")
  async delete(@Res() res: Response): Promise<void> {
    return this.userService.delete(res)
  }

  // Real deletion
  @Post("/remove")
  async remove(@Res() res: Response): Promise<void> {
    return this.userService.remove(res)
  }

  // Obtain all users
  @Get("/getAll")
  async getAll(@Res() res: Response): Promise<void> {
    return this.userService.getAll(res)
  }

  // Update user status
  @Post("/updateStatus")
  async updateStatus(@Res() res: Response): Promise<void> {
    return this.userService.updateStatus(res)
  }
  // Obtain user number
  @Get("/count")
  async count(@Res() res: Response): Promise<void> {
    return await this.userService.count(res)
  }

  // Reset password
  @Post("/reset")
  async reset(
    @Body() body: object,
    @Res() res: Response,
    @Session() session: object
  ): Promise<void> {
    return this.userService.reset(body, res, session)
  }
}
